﻿using System;
using System.Collections.Generic;
using System.Linq;
using Identity;

namespace Fee
{
   
    /// <summary>
    ///     框架合同
    /// </summary>
    public class FrameworkContract
    {
        public string Name { get; set; }

        /// <summary>
        ///     合同号
        /// </summary>
        public string No { get; set; }

        /// <summary>
        ///     合同类型
        /// </summary>
        public ContractType ContractType { get; set; }

        /// <summary>
        ///     乙方机构
        /// </summary>
        public Vendor Vendor { get; set; }

        /// <summary>
        ///     投资接含税
        /// </summary>
        public decimal Amount { get; set; }

        public int Id { get; set; }

        /// <summary>
        ///     投资金额（万元）不含税
        /// </summary>
        public decimal AmountWithoutTax { get; set; }


        /// <summary>
        ///     降点信息
        /// </summary>
        public decimal ReductionAmount { get; set; }

        /// <summary>
        ///     合同状态
        /// </summary>
        public ContractStatus Status { get; set; }


        /// <summary>
        ///     签订时间
        /// </summary>
        public DateTimeOffset? SignTime { get; set; }

        /// <summary>
        ///     框加结束日期
        /// </summary>
        public DateTimeOffset? ExpireTime { get; set; }

        /// <summary>
        /// </summary>
        public string Comment { get; set; }

        /// <summary>
        /// </summary>
        public string ContractDescription { get; set; }

        public string EffectYear { get; set; }

        public string NetType { get; set; }

       // public IList<FrameworkContractProject> Projects { get; set; } = new List<FrameworkContractProject>();

        //public bool TryUpdateProject(Project project)
        //{
        //    var exist = Projects.FirstOrDefault(f =>
        //            (f.FrameworkContractId == Id || f.FrameworkContractId == 0 || Id == 0)
        //            &&
        //            f.ProjectId == project.Id
        //        )
        //        ;
        //    if (exist == null)
        //    {
        //        exist = new FrameworkContractProject
        //        {
        //            Project = project
        //        };

        //        Projects.Add(exist);
        //        return true;
        //    }

        //    return false;
        //}
    }


    //public class FrameworkContractProject
    //{
    //    public int ProjectId { get; set; }
    //    public int FrameworkContractId { get; set; }
    //    public FrameworkContract FrameworkContract { get; set; }
    //    public Project Project { get; set; }
    //}
}